<?php

namespace App\Http\Controllers\RabbitMq;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;

class Publisher extends Controller
{
    private $channel;
    public function __construct()
    {
      $connection = new AMQPStreamConnection('localhost', '5672',
        'guest', 'guest', '/');

      $this->channel = $connection->channel();
    }

    public function weixinMessage() {

      $this->channel->queue_bind('message.weixin', '');

      foreach (range(0, 10) as $index) {
        $message = new AMQPMessage('i am weixin message ' . $index );
        $this->channel->basic_publish($message);
      }

    }

    public function emailMessage() {

    }

    public function smsMessage() {

    }
}
